package com.koron.standard.riskSources.service;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.koron.standard.riskSources.bean.po.RiskItem;
import com.koron.standard.riskSources.mapper.RiskItemMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 作业风险(RiskItem)表服务实现类
 *
 * @author jzp
 * @since 2021-09-10
 */
@Service
@Slf4j
public class RiskItemService extends ServiceImpl<RiskItemMapper, RiskItem> {

    public List<RiskItem> listBySourceId(String sourceId) {
        LambdaQueryWrapper<RiskItem> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(RiskItem::getSourceId, sourceId);
        return list(wrapper);
    }

    public List<RiskItem> listBySourceIds(List<String> sourceIds) {
        LambdaQueryWrapper<RiskItem> wrapper = new LambdaQueryWrapper<>();
        wrapper.in(RiskItem::getSourceId, sourceIds);
        return list(wrapper);
    }

    public void truncateData() {
        log.info("清除风险源项表数据");
        getBaseMapper().truncateData();
    }

}
